package com.zpself.module.算法练习.算法.排序算法;

import org.junit.Test;

/**
 * @author By ZengPeng
 * @Description 选择拿arI이],-直比上去,小的就换给ar[I이j:->第一轮ar[]就是最小的了
 * @date in  2021/4/9 10:57
 * @Modified By
 */
public class 选择排序_O_n2 {
    @Test
    public void main(){
        int[] number = new int[]{12,5,6,4,7,8,5,101,0,72};
        for (int i : xuanZhe(number)) {
            System.out.print(i+",");
        }
    }

    private int[] xuanZhe(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = i+1; j < arr.length; j++) {
               if(arr[i]>arr[j]){
                   arr[i] =arr[i]^arr[j];
                   arr[j] =arr[i]^arr[j];
                   arr[i] =arr[i]^arr[j];
               }
            }

        }
        return arr;
    }
}
